package common;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @author： pang-yun
 * @date： 2021-11-02 15:09
 * 功能目的 ：用于
 */

@Slf4j
public class ParkUnPark {
    public static void main(String[] args) {
        Thread test = new Thread(() -> {
            log.info("start!");
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            LockSupport.park();
            log.info("park!");
        }, "test");
        test.start();

        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        log.info("unpark!");
        LockSupport.unpark(test);
    }
}
